#include<iostream>

using namespace std;

typedef long long ll;
const int N = 5e6 + 10;
ll t[N],a[N];

int main()
{
	int n, p; cin >> n >> p;
	for (int i = 1; i <= n; i++)
	{
		 cin >> a[i];
		t[i] = a[i] - a[i - 1];
	}
	while (p--)
	{
		int a, b, c; cin >> a >> b >> c;
		t[a] += c; t[b + 1] -= c;
	}
	ll Min = 0x3f3f3f3f3f3f3f3f;
	for (int i = 1; i <= n; i++)
	{
		t[i] += t[i - 1];
		Min = min(Min, t[i]);
	}
	cout << Min;
	return 0;
}

